package com.baizhi.controller;

import com.baizhi.po.CategoriesPO;
import com.baizhi.po.QueryCategoriesPO;
import com.baizhi.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RefreshScope
@RestController
@RequestMapping("categories")
public class CategoriesController {

    @Autowired
    private CategoryService categoryService;

    @GetMapping
    public List<QueryCategoriesPO> queryAll() {
        List<QueryCategoriesPO> queryCategoriesPOS = categoryService.queryAll();
        return queryCategoriesPOS;
    }

    @GetMapping("{id}")
    public CategoriesPO queryById(@PathVariable("id") Integer id) {
        CategoriesPO categoriesPO = categoryService.queryById(id);
        return categoriesPO;
    }
}
